"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.cancelTimeout = cancelTimeout;
exports.requestTimeout = requestTimeout;

var _runtime = require("@tarojs/runtime");

function cancelTimeout(timeoutID) {
  (0, _runtime.cancelAnimationFrame)(timeoutID.id);
}

function requestTimeout(callback, delay) {
  var start = (0, _runtime.now)();

  function tick() {
    if ((0, _runtime.now)() - start >= delay) {
      // eslint-disable-next-line no-useless-call
      callback.call(null);
    } else {
      timeoutID.id = (0, _runtime.requestAnimationFrame)(tick);
    }
  }

  var timeoutID = {
    id: (0, _runtime.requestAnimationFrame)(tick)
  };
  return timeoutID;
}